package busuanzi.util;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static java.lang.Runtime.getRuntime;

/**
 * Created by bruce on 16/1/10.
 */
public class Executors2 {

    public static final ExecutorService defaultExecutor = Executors2.ioCost();
    public static final int PROCESSORS = getRuntime().availableProcessors();

    public static ExecutorService cpuCost() {
        return Executors.newFixedThreadPool(PROCESSORS + 1);
    }

    public static ExecutorService ioCost() {
        return Executors.newFixedThreadPool(PROCESSORS * 2 + 1);
    }
}
